package com.ruoyi.video.mapper;

import java.util.List;
import com.ruoyi.video.domain.UploadTask;
import org.apache.ibatis.annotations.*;

/**
 * videoMapper接口
 * 
 * @author Larry
 * @date 2024-03-22
 */
@Mapper
public interface UploadTaskMapper 
{
    /**
     * 查询video
     * 
     * @param id video主键
     * @return video
     */
    public UploadTask selectUploadTaskById(Long id);

    /**
     * 查询video列表
     *
     * @param uploadTask video
     * @return video集合
     */
    public List<UploadTask> selectUploadTaskList(UploadTask uploadTask);

    /**
     * 新增video
     *
     * @param uploadTask video
     * @return 结果
     */
    public int insertUploadTask(UploadTask uploadTask);

    /**
     * 修改video
     *
     * @param uploadTask video
     * @return 结果
     */
    public int updateUploadTask(UploadTask uploadTask);

    /**
     * 删除video
     *
     * @param id video主键
     * @return 结果
     */
    public int deleteUploadTaskById(Long id);

    /**
     * 批量删除video
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteUploadTaskByIds(Long[] ids);
    @Select("SELECT * FROM upload_task WHERE file_md5 = #{md5} limit 1")
    UploadTask getByMd5(String md5);
    @Insert("insert into upload_task(id, current, file_md5, bucket_name, file_url, total_size, chunk_size, chunk_num) " +
            "values (#{id}, #{current}, #{fileMd5}, #{bucketName}, #{fileUrl}, #{totalSize}, #{chunkSize}, #{chunkNum})")
    void insertOne(UploadTask uploadTask);

    @Update("update upload_task set current = #{current} where file_md5 = #{md5}")
    void updateByMd5(@Param("current") Integer current, @Param("md5") String md5);
}
